package iscript.gameFramework.GameLite.content
{
	import flash.utils.Dictionary;
	import iscript.gameFramework.GameLite.events.GameContentEvent;
	
	internal class ObjectContent implements IGameContent
	{
		
		private var _data:Dictionary = new Dictionary();
		private var _gameContent:GameContent;
		
		
		public function ObjectContent(gameContent:GameContent)
		{
			_gameContent = gameContent;
		}

	    public function get KEY():Array { return _data.getAllKeys() }	
		
		public function add(key:*, value:Object):void
		{
			if (_data[key] == null) {
				_data[key] = value;
				var event:GameContentEvent = new GameContentEvent(GameContentEvent.ADDOBJECTCONTENT);
				   event.key = key;
				   event.content = value;
				   _gameContent.dispatchEvent(event);
				   
				 var e:GameContentEvent = new GameContentEvent(GameContentEvent.EVERYTHING)
					 e.key = key;
					 e.content = value;
					 _gameContent.dispatchEvent(e);
				}
		}
		
		public function get(key:*):Object
		{
			return _data[key]
		}
		
		public function contain(key:*):Boolean {
			  return  _data[key] != null;
		}
		
		public function remove(key:*):void
		{
			delete  _data[key];
		}
		 
	}

}